<script type="text/ecmascript-6">
  import Navbar from '../../components/base/navbar.vue';
  export default{
      name:"coupon_select",
      components:{
        Navbar
      },
      props: {
        coupon: Array,
        show: Boolean,
        couponChecked: Array,
        couponSelected: Object,
        isList: Boolean
      },
      methods:{
          handleBack(){
//              this.show = false;
              EventBus.$emit("on-change",false);
//            this.showPageCouponSel=false;
          },
          subSel(){
              window.addEventListener('popstate',this.handleBack);
              if(this.cpChecked.length>0){
                  this.cpSelected = this.cpChecked[0]
                  window.history.back();
              }
              else{
                  this.$Modal.info({title:"消息提示",body:"请选择野练PASS！"});
              }
          }
      },
      data(){
          return {
              cpChecked:this.couponChecked,
              cpSelected:this.couponSelected
          }
      },
      watch:{
          show(v){
              if(v){
                  const page =this.$route.query.page;
                  if(page!='sel_coupon'){
//                      this.$router.replace({name:this.$route.name,query:{'page': 'sel_coupon'}});
                      let url="#"+this.$route.fullPath+'?page=sel_coupon';
                      window.history.pushState('sel_coupon', '选择野练PASS', url);
                  }
              }
              window.addEventListener('popstate',this.handleBack);
          },
          cpChecked(v){
              EventBus.$emit('on-checked-change',v);
          },
          cpSelected(v){
              EventBus.$emit('on-selected-change',v);
          }
      }
  }
</script>
